package gazzera.swing.network;

import gazzera.swing.model.*;
import gazzera.utils.*;

import java.awt.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;

public class GroupsRenderer  extends JLabel
                           implements TableCellRenderer {
    Border unselectedBorder = null;
    Border selectedBorder = null;
    boolean isBordered = true;

    public GroupsRenderer(boolean isBordered) {
        super();
    	this.isBordered = isBordered;
        setOpaque(true); 
    }

    public Component getTableCellRendererComponent(
                            JTable table, Object o,
                            boolean isSelected, boolean hasFocus,
                            int row, int column) {
        
    	Connection c = (Connection)o;
    	String x = Str.join(c.groups, ", ");
    	x = "<html><small style=\"color:#66aa66\">"+x+"</small></html>";
    	
    	
    	if(isSelected)
    	{
    		setBackground(table.getSelectionBackground());//new Color(0xb8,0xcf,0xe5));
    	}
    	else
    	{
    		setBackground(table.getBackground());
    	}
    	setForeground(isSelected ? Color.WHITE : Color.BLACK);
        setText(x);
        
        return this;
    }
}
